package com.yl.flink.filter;

import com.yl.entity.MultiDataEntity;
import com.yl.util.SUtil;
import org.apache.flink.api.java.functions.KeySelector;

/**
 * @author wlf
 * @since 2022/8/26
 */
public class TargetSelector implements KeySelector<MultiDataEntity, String> {

    /**
     * 根据项目id和测点id分组
     */
    @Override
    public String getKey(MultiDataEntity multiDataEntity) throws Exception {
        Integer projectId = multiDataEntity.getProject().getId();
        String typeTag = multiDataEntity.getTargetType().getTag();
        Integer targetId = multiDataEntity.getTarget().getId();
        return SUtil.fmt(projectId, typeTag, targetId);
    }
}
